﻿using Microsoft.Extensions.DependencyInjection;
using StockUI.ViewModels;
using System.Windows.Controls;
using System.Windows.Input;


namespace StockUI.Views
{
    /// <summary>
    /// Home.xaml 的交互逻辑
    /// </summary>
    public partial class Cgfx : UserControl
    {
        public Cgfx()
        {
            InitializeComponent();
            this.DataContext = App.Current.Services.GetService<CgfxViewModel>();
        }
        protected void HandleDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListView listView = sender as ListView;
            if (listView != null)
            {
                // 获取被双击的数据项
                var item = listView.SelectedItem;

                var mainmodel = this.DataContext as CgfxViewModel;
                mainmodel.AddItemCommand.Execute(item);
            }

        }
    }
}
